﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.FrameWork;
using LTJ.Entity;
using LTJ.Common;
using System.Data;

namespace uswinweb.datacontrol
{
    public partial class userList : System.Web.UI.UserControl
    {
        public int groupID = SASRequest.GetInt("gid", 0);
        public DataTable userTab = new DataTable();
        public string strWhere = " 1=1 ";
        public int pagesize = 10;
        public int pageindex = SASRequest.GetInt("currentPage", 1);
        public string action = SASRequest.GetString("action");
        public string parpms = SASRequest.GetString("parms").Trim();
        public string type = "1";
        public string _str = "";
        public string pageList = "";
        public string orderstr = "  ";
        public userList()
        {
            int recordcount = 0;
            type = SASRequest.GetString("type");
            if (action == "del")
            {
                int msg = Users.RemoveUser(parpms, 0);
            }
            if (groupID != 0 )
            {
                strWhere += " and gid=" + groupID;
            }
            if (action == "search")
            {
                if (parpms != "")
                {
                    strWhere += " and lname like '%" + parpms + "%' ";
                }
            }
            recordcount = Users.GetUsersCount(strWhere);
            userTab = Users.GetUsersByPage(pageindex, pagesize, strWhere, orderstr);
            pageList = GetPageList(recordcount, pagesize, pageindex);
        }
        public string GetPageList(int recordcount, int pagesize, int currentpage)
        {
            if (SASRequest.GetInt("postnumber", 0) > 0)
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "userList.ascx", "postnumber=" + SASRequest.GetInt("postnumber", 0), "showdata");
            }
            else
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "userList.ascx", "action=" + action + "&gid=" + groupID + "&parms=" + parpms + "", "showdata");
            }
        }
    }

}